Skip to content

docs: document reducer context random APIs#5306

Open
clockwork-labs-bot wants to merge 1 commit into
masterfrom
docs/reducer-context-random-api
Open

docs: document reducer context random APIs#5306
clockwork-labs-bot wants to merge 1 commit into
masterfrom
docs/reducer-context-random-api

Conversation

@clockwork-labs-bot

@clockwork-labs-bot clockwork-labs-bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add reducer context examples for deterministic random values across TypeScript, C#, Rust, and C++
  • clarify the context-provided random API usage that the agent skills already reference
  • correct the C++ example to match the SDK's inclusive gen_range(min, max) behavior

Validation

  • pnpm --dir docs build passed.
    • Docusaurus emitted the existing llms-txt warning for /docs/ask-ai/ask-ai, then completed successfully.
  • TypeScript snippet calls typechecked with tsc against sdks/typescript/src/server/rng.ts and sdks/typescript/src/server/sys.d.ts:
    • ctx.random()
    • ctx.random.integerInRange(1, 6)
    • ctx.random.fill(new Uint8Array(16))
  • Rust RNG context examples passed existing doctests:
    • cargo test -p spacetimedb --doc rng --features rand
  • C++ snippet syntax checked against the SDK headers:
    • clang++ -std=c++20 -Icrates/bindings-cpp/include -x c++ -fsyntax-only -
    • The compile emitted existing warning noise for WASM import/export attributes, but exited successfully.
  • C# was not compiled locally because dotnet is not installed on this host. The documented ctx.Rng.NextDouble() and ctx.Rng.Next(1, 7) calls were checked against the generated/runtime context source where ReducerContext.Rng is a System.Random.

Notes

  • A package-wide TypeScript declarations build was not used as validation here because this checkout currently fails before the snippet on missing optional Solid typings (solid-js / solid-js/store).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant